import {getRequest} from "@/utils/request.js";

export async function getChatTargetList() {
  try {
      return await getRequest("/heaven-server/message/auth/list-chat-targets");
  } catch (e) {
    console.log('获取聊天对象失败',e);
    return {code: -1, msg: '获取聊天对象失败-'+e.message};
  }
}

export async function getChatTargetInfo(userId) {
  try {
    return await getRequest("/heaven-server/message/auth/get-userinfo", {userId});
  } catch (e) {
    console.log('获取聊天对象信息失败',e);
    return {code: -1, msg: '获取聊天对象信息失败-'+e.message};
  }
}

export async function getChatHistories(userId, pageNum, pageSize = 10) {
  try {
    return await getRequest("/heaven-server/message/auth/get-chat-history", {targetUserId: userId, pageSize, pageNum});
  } catch (e) {
    console.log('获取聊天历史失败',e);
    return {code: -1, msg: '获取聊天历史失败-'+e.message};
  }
}